﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FruitWeigher
{
	public partial class UIEndMessageBox : UserControl
	{
		public UIEndMessageBox()
		{
			// 为初始化变量所必需
			InitializeComponent();
            GSystem.UIEndMessageBox = this;
            Ani_Hide.Completed += new EventHandler(Ani_Hide_Completed);
            Btn_PlayAgin.Click += new RoutedEventHandler(Btn_PlayAgin_Click);
		}

        void Btn_PlayAgin_Click(object sender, RoutedEventArgs e)
        {
            Ani_Hide.Begin();
            //重玩
        }
        void Ani_Hide_Completed(object sender, EventArgs e)
        {
            GSystem.Root.StartNewGame();
            this.Visibility = Visibility.Collapsed;
        }
        public void ShowThisInterface(int score)
        {
            this.Visibility = Visibility.Visible;
            ScoreSum.Text = score.ToString();
            var hs = GSystem.GetHighestScore();
            if (score >= hs)
            {
                HighestScore.Text = score.ToString();
                GSystem.SetHighestScore(score);
            }
            else
                HighestScore.Text = hs.ToString();
            Ani_SHow.Begin();
        }
        public void HideThisInterface()
        {
            Ani_Hide.Begin();
        }
	}
}